import Vue from 'vue'
import App from './App'
import router from './router'
import vuePicturePreview from 'vue-picture-preview'
Vue.use(vuePicturePreview)

// 按需导入mint-ui插件
// import { Header, Swipe, SwipeItem, Button, Lazyload } from  'mint-ui'
// Vue . component (Header .name, Header)
// Vue . component (Swipe .name, Swipe )
// Vue . component (SwipeItem.name , SwipeItem)
// Vue . component (Button. name,Button)
// Vue . use (Lazyload) ;       


// 配置vuex的步骤
import Vuex from 'vuex'
Vue.use(Vuex)
// 4 newvuestore()
var store = new Vuex.Store({
  state: {  //this.$store.state++
    car: []

  },
  mutation: {  //this.$store.commit
    addToCar(state, goodsinfo) {
      
      var flag = false
      state.car.some(item => {
        if (item.id == goodinfo.id) { 
          item.count += parseInt(goodsinfo.count)
          flag = true
          return true  
        }
      })
      if(!flag){
        state.car.push(goodsinfo)
      }
    }
  }
})




import MintUI from "mint-ui";
Vue.use(MintUI);
import "mint-ui/lib/style.css";
Vue.http.options.root = 'http://www.liulongbin.top:3005/api/';
Vue.config.productionTip = false
import moment from 'moment'
Vue.filter('dateFormat', function (dataStr, pattern = "YYYY-MM-DD HH:mm:ss") {
  return moment(dataStr).format(pattern)
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App),
  store
})


